package com.xiaohui.user.designPattern.template.prod;

import com.xiaohui.com.xiaohui.bean.Result;

public class ApiTemplate {
    public void execute(Result result, Action action){
        try {
            action.validate();
            action.execute();
            action.after();
            result.setSuccess(true);
            result.setMessage("执行成功");
            result.setCode(200);
        } catch (Exception e) {
            result.setSuccess(false);
            result.setMessage(e.getMessage());
            result.setCode(500);
        }


    }
}
